import React from 'react'
import { useLocation, useSearchParams } from 'react-router-dom'

function RouterPassLocationSon() {
  const location = useLocation()
  console.log(location.search)

  // useSearchParams 是一个标准的 hook 函数
  const [searchParams] = useSearchParams()
  // console.log(searchParams.get('name'))
  // console.log(searchParams.get('age'))
  const data = Object.fromEntries(searchParams)
  // console.log(data)

  return (
    <div>
      <h4>路由传参2的子页面：</h4>
      <h4>
        传过来的url数据：name =》 {data.name}，age =》 {data.age}
      </h4>
    </div>
  )
}

export default RouterPassLocationSon
